package com.my.mybatis;

import com.my.mybatis.dao.UserDao;
import com.my.mybatis.entity.User;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Author:wangbin.
 * @Description.
 * @Date:Created in 16:42 2017/9/7.
 * @Modified By:
 */

public class ApplicationContextMain {

    public static void main(String[] args) {
        ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
        UserDao userDao=(UserDao) ctx.getBean("userDao");
        User user=new User();
        //添加两条数据
        user.setUsername("wangbin");
        user.setPassword("wangbin123");
        //userDao.addUser(user);
        //System.out.println("添加成功");

        // 查询数据
        //User user1 = userDao.getUser(user);
        //System.out.println(user1);

        // 删除数据
        //Integer flag = userDao.deleteUser(2);
        //System.out.println(flag);

        // 修改数据
        int flag = userDao.updateUser(user);
        System.out.println(flag);

    }
}
